package sk.hackcraft.multibox.android;

import java.util.LinkedList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import sk.hackcraft.multibox.android.net.GetPlaylistRequest;
import sk.hackcraft.multibox.android.net.HttpInterface;
import sk.hackcraft.multibox.android.net.RegistrationRequest;
import sk.hackcraft.multibox.android.net.Request;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;

public class NetService extends Service
{
	public static String REQUEST_REGISTRATION = "sk.hackcraft.multibox.android.REQUEST_REGISTRATION";
	public static String REGISTRATION_RESULT = "sk.hackcraft.multibox.android.REGISTRATION_RESULT";
	
	HttpInterface httpInterface = new HttpInterface(new Handler());
	
	LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
	
	@Override
	public void onCreate()
	{		
		
	}
	
	@Override
	public IBinder onBind(Intent arg0)
	{
		return null;
	}
	
	public class NetServiceBinder extends Binder
	{
		public NetService getService()
		{
			return NetService.this;
		}
	}
	
	public boolean isLogged()
	{
		return httpInterface.hasToken();
	}
	
	public void register(String name, String password)
	{
		RegistrationRequest request = new RegistrationRequest();
		request.setCallback(new Request.RequestCallback()
			{
				@Override
				public void run()
				{
					String result = data.toString();
					throw new RuntimeException(result);
				}
			}
		);
		
		httpInterface.run(request);
	}
	
	public void getPlaylist()
	{
		
	}
}
